<template>
  <el-card class="mt-20">
    <el-table
      :data="permissionList"
      border
      row-key="id"
      :expand-row-keys="['1']"
    >
      <el-table-column label="名称" prop="name" />
      <el-table-column label="权限值" prop="code" />
      <el-table-column label="跳转权限值" prop="toCode" />
      <el-table-column label="操作" align="center">
        <!-- <el-button type="primary" size="small" :icon="Plus" title="添加菜单" />
        <el-button type="warning" size="small" :icon="Edit" title="修改菜单" />
        <el-button type="danger" size="small" :icon="Delete" title="删除菜单" /> -->

        <PermissionButton
          type="primary"
          size="small"
          :icon="Plus"
          title="添加菜单"
          :permission="'btn.Permission.add'"
        />
        <PermissionButton
          type="warning"
          size="small"
          :icon="Edit"
          title="修改菜单"
          :permission="'btn.Permission.update'"
        />
        <PermissionButton
          type="danger"
          size="small"
          :icon="Delete"
          title="删除菜单"
          :permission="'btn.Permission.remove'"
        />
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script lang="ts">
export default {
  name: "XPermission",
};
</script>

<script lang="ts" setup>
import { getPermissionListApi } from "@/api/acl/permission";
import type { PermissionList } from "@/api/acl/model/roleModel";
import { ref, onMounted } from "vue";
import { Plus, Edit, Delete } from "@element-plus/icons-vue";
const permissionList = ref<PermissionList>([]);
const getPermissionList = async () => {
  const res = await getPermissionListApi();
  permissionList.value = res.children;
};
onMounted(getPermissionList);
</script>

<style scoped></style>
